<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>邮箱验证</title>
		<script>
			function checkForm(f)
			{
				//f就是form
				//var mail=document.getElementById("email");
				//表单元素获得元素的方式:form.元素名
				var mail=f.youremail.value;
				if(mail=="")
				{
					alert("邮件不能为空！");
					f.youremail.focus();
					return false;
				}
				if(mail.indexOf("@")<1)
				{
					alert("邮件格式不正确！");
					f.youremail.focus();
					return false;
				}
				var p=f.yourpass;
				if(p.value.length<6||p.value.length>30)
				{
					alert("密码长度必须在6-30之间！");
					p.focus();
					return false;
				}
				return true;
			}
			function checkMail(e)
			{
				var mail=e.value;
				if(mail=="")
				{
					alert("邮件不能为空！");
					e.focus();
					return false;
				}
				if(mail.indexOf("@")<1)
				{
					alert("邮件格式不正确！");
					e.focus();
					return false;
				}
			}
			function checkPass(p)
			{
				if(p.value.length<6||p.value.length>30)
				{
					alert("密码长度必须在6-30之间！");
					p.focus();
					return false;
				}
				return true;
			}
		</script>
	</head>
	<body>
		<form action="jq1.html" method="get" onsubmit="return checkForm(this)">
			<p>
				<label for="email">电子邮件</label>
				<input type="email" name="youremail" id="email" onblur="checkMail(this)">
			</p>
			<p>
				<label for="pass">密码</label>
				<input type="password" name="yourpass" id="pass" onblur="checkPass(this)">
			</p>
			<p>
				<input type="submit"  value="注册"/>
			</p>
		</form>
	</body>
</html>
